GBML manual / Effects

light_on

Switches this object’s light on or off. An object set as a light in Gbabel (Lighting: This is a light) starts on; off, it cuts no hole in a shroud and lights nothing. It does nothing on an object that is not set as a light.

Works differently on Game Boy - Switches this object's light on or off, as on the Advance. The Game Boy keeps the sprites near a light in their own shades; it cannot light the picture. Up to 4 lights.

Works differently on Game Boy Color - Switches this object's light on or off, as on the Advance. The Game Boy Color lights whole 8 by 8 pixel squares, with no soft edge and no color. Up to 4 lights, a picture of 3 palettes at most and 4 sprite palettes at most.

Works differently on Sega Genesis - The Sega Genesis has one dark level: half as bright as the picture. Every darkness number above 0 shows that same dark (a room set to 72 is no darker than one set to 50), and 0 is no dark at all. Each light cuts its hole in that dark, in the shape and size set in Gbabel and in the directions and sizes the code asks for; a light's hole is a picture made ahead of time, so a size or a direction the code works out while the game plays is shown as the nearest one made. An object stands in the light as a whole while its middle is in the light. A light near the edge of the screen is whole or gone, and an object lit by room lights keeps its own colors.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

light_on(on)

Arguments

NameType
onbool

Returns

Nothing.

Description

Switches this object's light on or off. An object whose Lighting setting is This is a light starts on; light_on(false) puts it out, light_on(true) lights it again. It is the call for a lamp that goes out, a torch that is blown out and re-lit, an alarm that blinks, a headlight that follows a switch.

While a light is off it does nothing at all: it cuts no hole in a room's darkness, and it lights nothing. An object that was lit by it goes back to its own colors within a fraction of a second. Switching it back on brings the same shape, size, direction, color and strength back: those are set in Gbabel, in the object's Adjust... window, and the call changes none of them.

See Room lighting for how a light is made and what it lights.

Only for an object set as a light

The call does nothing on an object whose Lighting setting is not This is a light. That is not a mistake in the game, so it never stops a build; Gbabel says so as a note, so you can tell a missing setting from a call that worked.

Example

light_on(!btn_held(BTN_A));

The light stays on, and goes out for as long as A is held. Put in a Step event, it is checked every frame, so the light follows the button at once.

A real capture, two pictures of one street lamp - lit, with a walker in its cone of light wearing its warm colors, then switched off, with the cone gone and the walker back in his own colorsA real capture, two pictures of one street lamp - lit, with a walker in its cone of light wearing its warm colors, then switched off, with the cone gone and the walker back in his own colors
A real capture, two pictures of one street lamp - lit, with a walker in its cone of light wearing its warm colors, then switched off, with the cone gone and the walker back in his own colors

On the GBA

The light’s shape, size and color come from the object’s Lighting setting, made ahead of time by the build, so switching costs nothing to compute. An object that is lit by room lights loses the light’s color within a fraction of a second (lit objects look for the nearest light about five times a second). A light in a room with no shroud cuts nothing at all, on or off.

See also: light_rotatelight_scalelight_flickerRoom lightingshroud_cutout